import instance from '@/util/http'
import { type cityInfo, type cityS, type relationTreeInfo } from '@/page/types/system/city'
import { type dictKeyInfo, type dictKeyS } from '@/page/types/system/dict/key'
import { type dictValueInfo, type dictValueS } from '@/page/types/system/dict/value'

/**
 * 获取城市菜单列表
 */
export const relationCity = async (data: relationTreeInfo) => instance.post('/system/city/relationTree', data)
/**
 *  字典key 分页
 * @param data
 */
export const pageDictKey = async (data: dictKeyS) => instance.post('/system/dict/key/page', data)
/**
 * 字典详情
 * @param id
 */
export const detailDictKey = async (id: string) => instance.get('/system/dict/key/detail', { id: id })
/**
 * 保存字典key
 * @param data
 */
export const saveDictKey = async (data: dictKeyInfo) => instance.post('/system/dict/key/save', data)
/**
 * 更新字典key
 * @param data
 */
export const updateDictKey = async (data: dictKeyInfo) => instance.put('/system/dict/key/update', data)
/**
 * 删除字典key
 * @param id
 */
export const delDictKey = async (id: string) => instance.delete('/system/dict/key/delete/' + id)
/**
 * 得到字典类型下拉列表
 * @param pid
 */
export const selectDictKey = async (pid: string | null) => instance.get('/system/dict/key/select', { pid: pid })

/**
 *  字典key 分页
 * @param data
 */
export const pageDictValue = async (data: dictValueS) => instance.post('/system/dict/value/page', data)
/**
 * 字典详情
 * @param id
 */
export const detailDictValue = async (id: string) => instance.get('/system/dict/value/detail', { id: id })
/**
 * 保存字典key
 * @param data
 */
export const saveDictValue = async (data: dictValueInfo) => instance.post('/system/dict/value/save', data)
/**
 * 更新字典key
 * @param data
 */
export const updateDictValue = async (data: dictValueInfo) => instance.put('/system/dict/value/update', data)
/**
 * 删除字典key
 * @param id
 */
export const delDictValue = async (id: string) => instance.delete('/system/dict/value/delete/' + id)

/**
 * 得到字典类型下拉列表
 * @param dictKey
 */
export const selectDictValue = async (dictKey: string | undefined) => instance.get('/system/dict/value/select/' + dictKey)
/**
 * 城市列表
 */
export const pageCity = async (data: cityS) => instance.post('/system/city/page', data)
/**
 * 保存城市
 */
export const saveCity = async (data: cityInfo) => instance.post('/system/city/save', data)
/**
 * 更新城市
 */
export const updateCity = async (data: cityInfo) => instance.put('/system/city/update', data)
/**
 * 删除城市
 */
export const deleteCity = async (id: string) => instance.delete('/system/city/delete/' + id)
/**
 * 城市详情
 */
export const detailCity = async (id: string) => instance.get('/system/city/detail/' + id)
/**
 * 获取枚举list
 */
export const getEnumList = (name: string) => instance.get('/system/enum/getList/' + name)
